package org.csu.mypetstore.service;


import java.util.List;
import org.csu.mypetstore.domain.Product;
import org.csu.mypetstore.persistence.ProductMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ProductService {
    @Autowired
    private ProductMapper productMapper;

    public List<Product> getProductList() {
        return productMapper.getProductList();
    }

    public List<Product> searchProductList(String keyword) {
        return productMapper.searchProductList("%" + keyword.toLowerCase() + "%");
    }

    public void insertProduct (Product product){
        productMapper.insertProduct(product);
    }

    public void insertInventory (Product product){
        productMapper.insertInventory(product);
    }

    public void deleteProduct (String itemId){
        productMapper.deleteProduct(itemId);
    }

    public void deleteInventory (String itemId){
        productMapper.deleteInventory(itemId);
    }

    public void updateProduct(Product product){
        productMapper.updateProduct(product);
    }
    public void updateInventory(Product product){
        productMapper.updateInventory(product);
    }

    public String getProductidByname(String name){
        return productMapper.getProductidByname(name);
    }

    public Product getProductByItemid (String itemId){
        return productMapper.getProductByItemid(itemId);
    }
}
